using System;
using System.Data;
using System.Configuration;
using Pheonix.Fashionzoomer.DAL;
using System.Data.SqlClient;
using System.Collections;
using Pheonix.CodeLibrary.Data;
using Pheonix.CodeLibrary;

/// <summary>
/// Summary description for Shop
/// </summary>

namespace Pheonix.Fashionzoomer.Entity.SqlServer2000
{
    [System.ComponentModel.DataObject]
    public class Shop : SqlServerDAO
    {
        #region Shop Private Fields

		private Int32 _id;
		private String _shopName;
		private String _shopLogoPath;
		private Int32 _shopOwnerUserId;
		private Decimal _rating;
		private Int32 _totalRater;
		private String _branchAddress;
		private String _email;
		private String _phone;
		private String _shopCode;
		private Int32 _itemCount;
		private Int32 _categoryCount;
		private Int32 _totalVisit;
		private DateTime _createdOn;
		private DateTime _lastUpdate;
		private Int32 _mainBranchShopId;
		private String _country;
		private Boolean _isFeatured;
		private String _keywords;
		private String _city;

        #endregion

        #region Shop Constractors

		public Shop(){}

		public Shop
		(
			Int32 id,
			String shopName,
			String shopLogoPath,
			Int32 shopOwnerUserId,
			Decimal rating,
			Int32 totalRater,
			String branchAddress,
			String email,
			String phone,
			String shopCode,
			Int32 itemCount,
			Int32 categoryCount,
			Int32 totalVisit,
			DateTime createdOn,
			DateTime lastUpdate,
			Int32 mainBranchShopId,
			String country,
			Boolean isFeatured,
			String keywords,
			String city

		)
		{
			this._id = id;
			this._shopName = shopName;
			this._shopLogoPath = shopLogoPath;
			this._shopOwnerUserId = shopOwnerUserId;
			this._rating = rating;
			this._totalRater = totalRater;
			this._branchAddress = branchAddress;
			this._email = email;
			this._phone = phone;
			this._shopCode = shopCode;
			this._itemCount = itemCount;
			this._categoryCount = categoryCount;
			this._totalVisit = totalVisit;
			this._createdOn = createdOn;
			this._lastUpdate = lastUpdate;
			this._mainBranchShopId = mainBranchShopId;
			this._country = country;
			this._isFeatured = isFeatured;
			this._keywords = keywords;
			this._city = city;
		}

        #endregion

        #region Shop Properties

		public Int32 Id
		{
			get{ return this._id; }
			set{ this._id = value; }
		}

		public String ShopName
		{
			get{ return this._shopName; }
			set{ this._shopName = value; }
		}

		public String ShopLogoPath
		{
			get{ return this._shopLogoPath; }
			set{ this._shopLogoPath = value; }
		}

		public Int32 ShopOwnerUserId
		{
			get{ return this._shopOwnerUserId; }
			set{ this._shopOwnerUserId = value; }
		}

		public Decimal Rating
		{
			get{ return this._rating; }
			set{ this._rating = value; }
		}

		public Int32 TotalRater
		{
			get{ return this._totalRater; }
			set{ this._totalRater = value; }
		}

		public String BranchAddress
		{
			get{ return this._branchAddress; }
			set{ this._branchAddress = value; }
		}

		public String Email
		{
			get{ return this._email; }
			set{ this._email = value; }
		}

		public String Phone
		{
			get{ return this._phone; }
			set{ this._phone = value; }
		}

		public String ShopCode
		{
			get{ return this._shopCode; }
			set{ this._shopCode = value; }
		}

		public Int32 ItemCount
		{
			get{ return this._itemCount; }
			set{ this._itemCount = value; }
		}

		public Int32 CategoryCount
		{
			get{ return this._categoryCount; }
			set{ this._categoryCount = value; }
		}

		public Int32 TotalVisit
		{
			get{ return this._totalVisit; }
			set{ this._totalVisit = value; }
		}

		public DateTime CreatedOn
		{
			get{ return this._createdOn; }
			set{ this._createdOn = value; }
		}

		public DateTime LastUpdate
		{
			get{ return this._lastUpdate; }
			set{ this._lastUpdate = value; }
		}

		public Int32 MainBranchShopId
		{
			get{ return this._mainBranchShopId; }
			set{ this._mainBranchShopId = value; }
		}

		public String Country
		{
			get{ return this._country; }
			set{ this._country = value; }
		}

		public Boolean IsFeatured
		{
			get{ return this._isFeatured; }
			set{ this._isFeatured = value; }
		}

		public String Keywords
		{
			get{ return this._keywords; }
			set{ this._keywords = value; }
		}

		public String City
		{
			get{ return this._city; }
			set{ this._city = value; }
		}


        #endregion

        #region Shop Static Methods

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Insert, true)]
        public static Int32 CreateNewShop
        (
			String shopName,
			String shopLogoPath,
			Int32 shopOwnerUserId,
			Decimal rating,
			Int32 totalRater,
			String branchAddress,
			String email,
			String phone,
			String shopCode,
			Int32 itemCount,
			Int32 categoryCount,
			Int32 totalVisit,
			DateTime createdOn,
			DateTime lastUpdate,
			Int32 mainBranchShopId,
			String country,
			Boolean isFeatured,
			String keywords,
			String city

        )
        {
            //creating an empty Shop object
            Shop shop = new Shop();
            shop.ShopName = shopName;
			shop.ShopLogoPath = shopLogoPath;
			shop.ShopOwnerUserId = shopOwnerUserId;
			shop.Rating = rating;
			shop.TotalRater = totalRater;
			shop.BranchAddress = branchAddress;
			shop.Email = email;
			shop.Phone = phone;
			shop.ShopCode = shopCode;
			shop.ItemCount = itemCount;
			shop.CategoryCount = categoryCount;
			shop.TotalVisit = totalVisit;
			shop.CreatedOn = createdOn;
			shop.LastUpdate = lastUpdate;
			shop.MainBranchShopId = mainBranchShopId;
			shop.Country = country;
			shop.IsFeatured = isFeatured;
			shop.Keywords = keywords;
			shop.City = city;

            return Shop.CreateNewShop(shop);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static bool UpdateShop
        (
			Int32 id,
			String shopName,
			String shopLogoPath,
			Int32 shopOwnerUserId,
			Decimal rating,
			Int32 totalRater,
			String branchAddress,
			String email,
			String phone,
			String shopCode,
			Int32 itemCount,
			Int32 categoryCount,
			Int32 totalVisit,
			DateTime createdOn,
			DateTime lastUpdate,
			Int32 mainBranchShopId,
			String country,
			Boolean isFeatured,
			String keywords,
			String city

        )
        {
            Shop shop = Shop.GetShopById(id);
            shop.ShopName = shopName;
			shop.ShopLogoPath = shopLogoPath;
			shop.ShopOwnerUserId = shopOwnerUserId;
			shop.Rating = rating;
			shop.TotalRater = totalRater;
			shop.BranchAddress = branchAddress;
			shop.Email = email;
			shop.Phone = phone;
			shop.ShopCode = shopCode;
			shop.ItemCount = itemCount;
			shop.CategoryCount = categoryCount;
			shop.TotalVisit = totalVisit;
			shop.CreatedOn = createdOn;
			shop.LastUpdate = lastUpdate;
			shop.MainBranchShopId = mainBranchShopId;
			shop.Country = country;
			shop.IsFeatured = isFeatured;
			shop.Keywords = keywords;
			shop.City = city;

            return Shop.UpdateShop(shop);
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Update, true)]
        public static bool DeleteShop
        (
            Int32 id
        )
        {
            //Validate Input
            if (id <= GetIdMinValue)
                throw (new ArgumentOutOfRangeException("id in Shop"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@Id", SqlDbType.Int, 0, ParameterDirection.Input, id);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_DELETESHOP);
            GetOneData(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == 0 ? false : true);

        }

        public static bool DeleteShopList(System.Collections.Generic.List<Int32> idListToDelete)
        {
            //Validate Input
            foreach (Int32 id in idListToDelete)
                if (id <= GetIdMinValue)
                    throw (new ArgumentOutOfRangeException("id in Shop"));

            //performing deletion operation //

            string csvString = Utility.MakeCSV(idListToDelete);

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            AddParameterToSqlCmd(sqlCmd, "@IdList", SqlDbType.NVarChar, csvString.Length, 
                ParameterDirection.Input, csvString);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_DELETESHOPLIST);
            GetOneData(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == idListToDelete.Count ? true : false);
        }
		
		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
		public static CustomCollection<Shop> GetShopByShopOwnerUserId(Int32 shopOwnerUserId)
		{
			if(shopOwnerUserId <= GetIdMinValue)
				throw (new ArgumentOutOfRangeException("shopOwnerUserId in Shop"));

			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@ShopOwnerUserId", SqlDbType.Int, 0, ParameterDirection.Input, shopOwnerUserId);
			SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETSHOPBYSHOPOWNERUSERID);
			GenerateCollectionFromReader dg = new GenerateCollectionFromReader(GenerateShopCollectionFromReader);
			CustomCollection<Shop> objCollection = ((CustomCollection<Shop>)GetAllData(sqlCmd, dg));

			if (objCollection.Count > 0)
				return objCollection;
			else
				return null;
		}

		[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
		public static CustomCollection<Shop> GetShopByMainBranchShopId(Int32 mainBranchShopId)
		{
			if(mainBranchShopId <= GetIdMinValue)
				throw (new ArgumentOutOfRangeException("mainBranchShopId in Shop"));

			SqlCommand sqlCmd = new SqlCommand();
			AddParameterToSqlCmd(sqlCmd, "@MainBranchShopId", SqlDbType.Int, 0, ParameterDirection.Input, mainBranchShopId);
			SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETSHOPBYMAINBRANCHSHOPID);
			GenerateCollectionFromReader dg = new GenerateCollectionFromReader(GenerateShopCollectionFromReader);
			CustomCollection<Shop> objCollection = ((CustomCollection<Shop>)GetAllData(sqlCmd, dg));

			if (objCollection.Count > 0)
				return objCollection;
			else
				return null;
		}

        #endregion

        #region Shop Instance Methods
        
        public bool Save()
		{
			if(Id <= GetIdMinValue)
			{
				Int32 TempId=CreateNewShop(this);
				if(TempId>0)
				{
					_id=TempId;
					return true;
				}
				else
				{
					// error occurs
					return false;
				}
			}
			else
			{	//This is a update Command
				return (UpdateShop(this));
			}
		}

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<Shop> GetAllShop()
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETALLSHOP);
            GenerateCollectionFromReader result = new GenerateCollectionFromReader(GenerateShopCollectionFromReader);
            CustomCollection<Shop> objCollection = ((CustomCollection<Shop>)GetAllData(sqlCmd, result));

            return objCollection;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static CustomCollection<Shop> GetAllShopPaged(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            //Validate Input
            if (orderBy == "")
                orderBy = "Id";

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@orderby", SqlDbType.VarChar, 50, ParameterDirection.Input, orderBy);
            AddParameterToSqlCmd(sqlCmd, "@startRowIndex", SqlDbType.Int, 0, ParameterDirection.Input, startRowIndex);
            AddParameterToSqlCmd(sqlCmd, "@maximumRows", SqlDbType.Int, 0, ParameterDirection.Input, maximumRows);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETALLSHOPPAGED);

            GenerateCollectionFromReader result = new GenerateCollectionFromReader(GenerateShopCollectionFromReader);
            CustomCollection<Shop> objCollection = ((CustomCollection<Shop>)GetAllData(sqlCmd, result));
            return objCollection;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static int GetAllShopPagedCount(String orderBy, Int32 startRowIndex, Int32 maximumRows)
        {
            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();

            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETALLSHOPPAGEDCOUNT);
            GetOneData(sqlCmd);

            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return returnValue;
        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, true)]
        public static Shop GetShopById(Int32 id)
        {
            if (id <= GetIdMinValue)
                throw (new ArgumentOutOfRangeException("id in Shop"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@Id", SqlDbType.Int, 0, ParameterDirection.Input, id);
            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_GETSHOPBYID);
            GenerateCollectionFromReader result = new GenerateCollectionFromReader(GenerateShopCollectionFromReader);
            CustomCollection<Shop> objCollection = ((CustomCollection<Shop>)GetAllData(sqlCmd, result));

            if (objCollection.Count > 0)
                return (Shop)objCollection[0];
            else
                return null;
        }

        public static Int32 CreateNewShop(Shop newShop)
        {
            // validate Parameters
            if (newShop == null)
                throw (new ArgumentNullException("newShop in Shop"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);

            AddParameterToSqlCmd(sqlCmd, "@ShopName", SqlDbType.NVarChar, 64, ParameterDirection.Input, newShop.ShopName);
			AddParameterToSqlCmd(sqlCmd, "@ShopLogoPath", SqlDbType.NVarChar, 128, ParameterDirection.Input, newShop.ShopLogoPath);
			AddParameterToSqlCmd(sqlCmd, "@ShopOwnerUserId", SqlDbType.Int, 0, ParameterDirection.Input, newShop.ShopOwnerUserId);
			AddParameterToSqlCmd(sqlCmd, "@Rating", SqlDbType.Decimal, 0, ParameterDirection.Input, newShop.Rating);
			AddParameterToSqlCmd(sqlCmd, "@TotalRater", SqlDbType.Int, 0, ParameterDirection.Input, newShop.TotalRater);
			AddParameterToSqlCmd(sqlCmd, "@BranchAddress", SqlDbType.NVarChar, 512, ParameterDirection.Input, newShop.BranchAddress);
			AddParameterToSqlCmd(sqlCmd, "@Email", SqlDbType.NVarChar, 64, ParameterDirection.Input, newShop.Email);
			AddParameterToSqlCmd(sqlCmd, "@Phone", SqlDbType.NVarChar, 32, ParameterDirection.Input, newShop.Phone);
			AddParameterToSqlCmd(sqlCmd, "@ShopCode", SqlDbType.NVarChar, 100, ParameterDirection.Input, newShop.ShopCode);
			AddParameterToSqlCmd(sqlCmd, "@ItemCount", SqlDbType.Int, 0, ParameterDirection.Input, newShop.ItemCount);
			AddParameterToSqlCmd(sqlCmd, "@CategoryCount", SqlDbType.Int, 0, ParameterDirection.Input, newShop.CategoryCount);
			AddParameterToSqlCmd(sqlCmd, "@TotalVisit", SqlDbType.Int, 0, ParameterDirection.Input, newShop.TotalVisit);
			AddParameterToSqlCmd(sqlCmd, "@CreatedOn", SqlDbType.DateTime, 0, ParameterDirection.Input, newShop.CreatedOn);
			AddParameterToSqlCmd(sqlCmd, "@LastUpdate", SqlDbType.DateTime, 0, ParameterDirection.Input, newShop.LastUpdate);
			AddParameterToSqlCmd(sqlCmd, "@MainBranchShopId", SqlDbType.Int, 0, ParameterDirection.Input, newShop.MainBranchShopId);
			AddParameterToSqlCmd(sqlCmd, "@Country", SqlDbType.NVarChar, 150, ParameterDirection.Input, newShop.Country);
			AddParameterToSqlCmd(sqlCmd, "@IsFeatured", SqlDbType.Bit , 0, ParameterDirection.Input, newShop.IsFeatured);
			AddParameterToSqlCmd(sqlCmd, "@Keywords", SqlDbType.NVarChar, 512, ParameterDirection.Input, newShop.Keywords);
			AddParameterToSqlCmd(sqlCmd, "@City", SqlDbType.NVarChar, 150, ParameterDirection.Input, newShop.City);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_CREATENEWSHOP);
            GetOneData(sqlCmd);
            return ((Int32)sqlCmd.Parameters["@ReturnValue"].Value);

        }

        public static bool UpdateShop(Shop newShop)
        {
            // validate Parameters
            if (newShop == null)
                throw (new ArgumentNullException("newShop"));

            // Execute SQL Command
            SqlCommand sqlCmd = new SqlCommand();
            AddParameterToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);

            AddParameterToSqlCmd(sqlCmd, "@Id", SqlDbType.Int, 0, ParameterDirection.Input, newShop.Id);
            AddParameterToSqlCmd(sqlCmd, "@ShopName", SqlDbType.NVarChar, 64, ParameterDirection.Input, newShop.ShopName);
			AddParameterToSqlCmd(sqlCmd, "@ShopLogoPath", SqlDbType.NVarChar, 128, ParameterDirection.Input, newShop.ShopLogoPath);
			AddParameterToSqlCmd(sqlCmd, "@ShopOwnerUserId", SqlDbType.Int, 0, ParameterDirection.Input, newShop.ShopOwnerUserId);
			AddParameterToSqlCmd(sqlCmd, "@Rating", SqlDbType.Decimal, 0, ParameterDirection.Input, newShop.Rating);
			AddParameterToSqlCmd(sqlCmd, "@TotalRater", SqlDbType.Int, 0, ParameterDirection.Input, newShop.TotalRater);
			AddParameterToSqlCmd(sqlCmd, "@BranchAddress", SqlDbType.NVarChar, 512, ParameterDirection.Input, newShop.BranchAddress);
			AddParameterToSqlCmd(sqlCmd, "@Email", SqlDbType.NVarChar, 64, ParameterDirection.Input, newShop.Email);
			AddParameterToSqlCmd(sqlCmd, "@Phone", SqlDbType.NVarChar, 32, ParameterDirection.Input, newShop.Phone);
			AddParameterToSqlCmd(sqlCmd, "@ShopCode", SqlDbType.NVarChar, 100, ParameterDirection.Input, newShop.ShopCode);
			AddParameterToSqlCmd(sqlCmd, "@ItemCount", SqlDbType.Int, 0, ParameterDirection.Input, newShop.ItemCount);
			AddParameterToSqlCmd(sqlCmd, "@CategoryCount", SqlDbType.Int, 0, ParameterDirection.Input, newShop.CategoryCount);
			AddParameterToSqlCmd(sqlCmd, "@TotalVisit", SqlDbType.Int, 0, ParameterDirection.Input, newShop.TotalVisit);
			AddParameterToSqlCmd(sqlCmd, "@CreatedOn", SqlDbType.DateTime, 0, ParameterDirection.Input, newShop.CreatedOn);
			AddParameterToSqlCmd(sqlCmd, "@LastUpdate", SqlDbType.DateTime, 0, ParameterDirection.Input, newShop.LastUpdate);
			AddParameterToSqlCmd(sqlCmd, "@MainBranchShopId", SqlDbType.Int, 0, ParameterDirection.Input, newShop.MainBranchShopId);
			AddParameterToSqlCmd(sqlCmd, "@Country", SqlDbType.NVarChar, 150, ParameterDirection.Input, newShop.Country);
			AddParameterToSqlCmd(sqlCmd, "@IsFeatured", SqlDbType.Bit , 0, ParameterDirection.Input, newShop.IsFeatured);
			AddParameterToSqlCmd(sqlCmd, "@Keywords", SqlDbType.NVarChar, 512, ParameterDirection.Input, newShop.Keywords);
			AddParameterToSqlCmd(sqlCmd, "@City", SqlDbType.NVarChar, 150, ParameterDirection.Input, newShop.City);

            SetCommandType(sqlCmd, CommandType.StoredProcedure, SPR_SHOP_UPDATESHOP);
            GetOneData(sqlCmd);
            int returnValue = (int)sqlCmd.Parameters["@ReturnValue"].Value;
            return (returnValue == 0 ? false : true);
        }

        #endregion

        #region Shop Related Collections
        /// <summary>
        /// Creates and returns a strongly typed collection of Shop custom entity. 
        /// The colelction is created through iterating on the IdataReader object which contains 
        /// Shop information, as a set of records, similar to tabular format.
        /// </summary>
        public static IList GenerateShopCollectionFromReader(IDataReader returnData)
        {

            //creating the instance of Shop collection
            CustomCollection<Shop> colShop = new CustomCollection<Shop>();

            //Iterating thriugh the data reader, to generate Shop collection.

            //getting the Shop collection by iterating thru the data reader
            while (returnData.Read())
            {
                //passing the Shop constructor parameters from the current instance of data reader fields.
                Shop newShop = new Shop
                (
                    returnData["id"] == System.DBNull.Value ? GetIdMinValue : (Int32)returnData["id"],
                    returnData["shop_name"] == System.DBNull.Value ? String.Empty : (String)returnData["shop_name"],
					returnData["shop_logo_path"] == System.DBNull.Value ? String.Empty : (String)returnData["shop_logo_path"],
					returnData["shop_owner_user_id"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["shop_owner_user_id"],
					returnData["rating"] == System.DBNull.Value ? Decimal.MinValue : (Decimal)returnData["rating"],
					returnData["total_rater"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["total_rater"],
					returnData["branch_address"] == System.DBNull.Value ? String.Empty : (String)returnData["branch_address"],
					returnData["email"] == System.DBNull.Value ? String.Empty : (String)returnData["email"],
					returnData["phone"] == System.DBNull.Value ? String.Empty : (String)returnData["phone"],
					returnData["shop_code"] == System.DBNull.Value ? String.Empty : (String)returnData["shop_code"],
					returnData["item_count"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["item_count"],
					returnData["category_count"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["category_count"],
					returnData["total_visit"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["total_visit"],
					returnData["created_on"] == System.DBNull.Value ? DateTime.MinValue : (DateTime)returnData["created_on"],
					returnData["last_update"] == System.DBNull.Value ? DateTime.MinValue : (DateTime)returnData["last_update"],
					returnData["main_branch_shop_id"] == System.DBNull.Value ? Int32.MinValue : (Int32)returnData["main_branch_shop_id"],
					returnData["country"] == System.DBNull.Value ? String.Empty : (String)returnData["country"],
					returnData["is_featured"] == System.DBNull.Value ? false : (Boolean)returnData["is_featured"],
					returnData["keywords"] == System.DBNull.Value ? String.Empty : (String)returnData["keywords"],
					returnData["city"] == System.DBNull.Value ? String.Empty : (String)returnData["city"]

                );
                //adding the Shop to the collection
                colShop.Add(newShop);
            }

            //returns the collection of Shop 
            return (colShop);
        }

        #endregion

        #region Constants and Default Values

        public static Int32 GetIdMinValue
        {
            get
            {
                return 0;
            }
        }

        //contants
        internal const string SPR_SHOP_CREATENEWSHOP = "spr_Shop_CreateNewShop";
        internal const string SPR_SHOP_UPDATESHOP = "spr_Shop_UpdateShop";
        internal const string SPR_SHOP_DELETESHOP = "spr_Shop_DeleteShop";
        internal const string SPR_SHOP_DELETESHOPLIST = "spr_Shop_DeleteShopList";
        internal const string SPR_SHOP_GETSHOPBYID = "spr_Shop_GetShopById";
        internal const string SPR_SHOP_GETALLSHOP = "spr_Shop_GetAllShop";
        internal const string SPR_SHOP_GETALLSHOPPAGED = "spr_Shop_GetAllShopPaged";
        internal const string SPR_SHOP_GETALLSHOPPAGEDCOUNT = "spr_Shop_GetAllShopPagedCount";

		//Foreign key contants
		internal const string SPR_SHOP_GETSHOPBYSHOPOWNERUSERID="spr_Shop_GetShopByShopOwnerUserId";
		internal const string SPR_SHOP_GETSHOPBYSHOPOWNERUSERIDPAGED="spr_Shop_GetShopByShopOwnerUserIdPaged";
		internal const string SPR_SHOP_GETSHOPBYSHOPOWNERUSERIDPAGEDCOUNT="spr_Shop_GetShopByShopOwnerUserIdPagedCount";
		internal const string SPR_SHOP_GETSHOPBYMAINBRANCHSHOPID="spr_Shop_GetShopByMainBranchShopId";
		internal const string SPR_SHOP_GETSHOPBYMAINBRANCHSHOPIDPAGED="spr_Shop_GetShopByMainBranchShopIdPaged";
		internal const string SPR_SHOP_GETSHOPBYMAINBRANCHSHOPIDPAGEDCOUNT="spr_Shop_GetShopByMainBranchShopIdPagedCount";
		
        #endregion
    }
}
